package WaiBao;

import java.util.Arrays;

public class ZhangLinBo {
    public static void main(String[] args) {
        String[] name = {"白玉(班长)", "张玲珠(纪律委员)", "小李(学习委员)", "李焕波(文艺委员)", "张曼荷", "李小山", "郑方云", "张青丝", "李湘平", "李吉凡", "王苗海", "张寒香",
                "张雅山", "李平夏", "张醉委", "郑晓晓", "李春梅", "王水云", "张天纯", "李焕波", "李夏荣", "张绿夏", "宁河", "李文", "张文柳", "张思思", "张斌安", "李戴秋",
                "李安", "张霖波(学生)"};//考生本人: 张霖波(学生)
        int[] age = {20, 21, 22, 18, 19, 21, 19, 21, 18, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 21, 20, 20};//最后一位：考生年龄:20

        double[] chenai1 = {67, 72, 84, 70, 79, 79, 78, 89, 81, 80, 91, 87, 85, 89, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 70, 87, 95};
        double[] chenai2 = {77, 82, 90, 76, 72, 77, 70, 79, 80, 70, 90, 77, 66, 95, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 94, 84, 95};
        double[] chenai3 = {81, 76, 84, 85, 77, 66, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 61, 84, 96};


        double xiaohei1;//代表每个学生的总分
        double xiaohei2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            xiaohei1 = chenai1[i] + chenai2[i] + chenai3[i];
//            xiaohei2 = (xiaohei1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + xiaohei1);
//            System.out.println(name[i] + "的平均分为:" + xiaohei2);
//        }


        double ling1 = 0, ling2 = 0;
        double[] dayu = new double[30];
//        for (int i = 0; i < 30; i++) {
//            ling1 = chenai1[i] + chenai2[i] +chenai3[i];
//            ling2= ( ling1 * 1.0) / 3;
//            dayu[i] =  ling2;
//        }
//
//        for (int i = 0; i < dayu.length - 1; i++) {
//            for (int j = 0; j < dayu.length - i - 1; j++) {
//                if (dayu[j] < dayu[j + 1]) {
//                    double tep = dayu[j];
//                    dayu[j] = dayu[j + 1];
//                    dayu[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(dayu[i]);
//        }


        double dongmian1 = 0, dongmian2 = 0, dongmian3 = 0;//计算每门课的平均分
        double sinan1 = 0,sinan2 = 0,sinan3 = 0;//计算每门课标准差
        double daogua1 = 0, daogua2 = 0, daogua3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i <chenai1.length; i++) {
            he += chenai1[i];
        }
        dongmian1 = (he * 1.0) / 30;
        System.out.println("生物化学的班级平均分为:" + dongmian1);
        double Sum = 0;
        for (int i = 0; i <chenai2.length; i++) {
            Sum += chenai2[i];
        }
        dongmian2 = (Sum * 1.0) / 30;
        System.out.println("物理化学的班级平均分为:" + dongmian2);
        double sum = 0;
        for (int i = 0; i <chenai3.length; i++) {
            sum += chenai3[i];
        }
        dongmian3 = (sum * 1.0) / 30;
        System.out.println("电子与电工技术的班级平均分为:" + dongmian3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < chenai1.length; i++) {
            c1 += (chenai1[i] - dongmian1) * (chenai1[i] - dongmian1);
        }
        sinan1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:" + sinan1);
        for (int i = 0; i < chenai2.length; i++) {
            c2 += (chenai2[i] - dongmian2) * (chenai2[i] - dongmian2);
        }
        sinan2 = Math.sqrt(c2*1.0/30);
        System.out.println("物理化学的班级标准差为:" + sinan2);

        for (int i = 0; i < chenai3.length; i++) {
            c3 += (chenai3[i] - dongmian3) * (chenai3[i] - dongmian3);
        }
        sinan3 = Math.sqrt(c3*1.0/30);
        System.out.println("电子与电工技术的班级标准差为:" + sinan3);
////
//
//
//        Arrays.sort(chenai1);
//        Arrays.sort(chenai2);
//        Arrays.sort(chenai3);
//        daogua1 = (chenai1[14] +chenai2[15]) * 1.0 / 2;
//        daogua2 = (chenai2[14] + chenai2[15]) * 1.0 / 2;
//        daogua3 = (chenai3[14] +chenai3[15]) * 1.0 / 2;
//        System.out.println("生物化学的中位数为:" + daogua1);
//        System.out.println("物理化学的中位数为:" + daogua2);
//        System.out.println("电子与电工技术的中位数为:" + daogua3);

    }
}
